package com.culture.system.service.impl;

import cn.hutool.core.date.DateUtil;
import com.culture.common.utils.DateUtils;
import com.culture.system.domain.CultureOrder;
import com.culture.system.mapper.CultureOrderMapper;
import com.culture.system.service.ICultureOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * 订单管理Service业务层处理
 *
 * @author lidongsheng
 * @date 2025-03-27
 */
@Service
public class CultureOrderServiceImpl implements ICultureOrderService {
    @Autowired
    private CultureOrderMapper cultureOrderMapper;

    /**
     * 查询订单管理
     *
     * @param id 订单管理主键
     * @return 订单管理
     */
    @Override
    public CultureOrder selectCultureOrderById(Long id) {
        return cultureOrderMapper.selectCultureOrderById(id);
    }

    /**
     * 查询订单管理列表
     *
     * @param cultureOrder 订单管理
     * @return 订单管理
     */
    @Override
    public List<CultureOrder> selectCultureOrderList(CultureOrder cultureOrder) {
        return cultureOrderMapper.selectCultureOrderList(cultureOrder);
    }

    /**
     * 新增订单管理
     *
     * @param cultureOrder 订单管理
     * @return 结果
     */
    @Override
    public int insertCultureOrder(CultureOrder cultureOrder) {
        synchronized (CultureProductServiceImpl.class) {
            cultureOrder.setBatchNo(DateUtil.format(new Date(), "yyyyMMddHHmmss"));
        }
        cultureOrder.setCreateTime(DateUtils.getNowDate());
        return cultureOrderMapper.insertCultureOrder(cultureOrder);
    }

    /**
     * 修改订单管理
     *
     * @param cultureOrder 订单管理
     * @return 结果
     */
    @Override
    public int updateCultureOrder(CultureOrder cultureOrder) {
        cultureOrder.setUpdateTime(DateUtils.getNowDate());
        return cultureOrderMapper.updateCultureOrder(cultureOrder);
    }

    /**
     * 批量删除订单管理
     *
     * @param ids 需要删除的订单管理主键
     * @return 结果
     */
    @Override
    public int deleteCultureOrderByIds(Long[] ids) {
        return cultureOrderMapper.deleteCultureOrderByIds(ids);
    }

    /**
     * 删除订单管理信息
     *
     * @param id 订单管理主键
     * @return 结果
     */
    @Override
    public int deleteCultureOrderById(Long id) {
        return cultureOrderMapper.deleteCultureOrderById(id);
    }
}
